package vn.ivs.taxiapp;

import vn.ivs.taxiapp.fragments.S001Fragment;
import vn.ivs.taxiapp.fragments.S006Fragment;
import vn.ivs.taxiapp.fragments.S008Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost.OnTabChangeListener;

import com.google.android.gms.maps.GoogleMap;

public class S001Activity extends FragmentActivity implements
		OnTabChangeListener {

	public static FragmentManager fragmentManager;
	private FragmentTabHost mTabHost;
	private ImageView imgHeaderBack;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_s001);

		fragmentManager = getSupportFragmentManager();

		imgHeaderBack = (ImageView) findViewById(R.id.imgHeaderBack);
		mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
		mTabHost.setup(this, getSupportFragmentManager(),
				android.R.id.tabcontent);

		mTabHost.addTab(
				mTabHost.newTabSpec("tabFolder").setIndicator(null,
						getResources().getDrawable(R.drawable.ic_folder)),
				S008Fragment.class, null);
		mTabHost.addTab(
				mTabHost.newTabSpec("tabSearch").setIndicator(null,
						getResources().getDrawable(R.drawable.ic_search)),
				S001Fragment.class, null);
		mTabHost.addTab(
				mTabHost.newTabSpec("tabBook").setIndicator(null,
						getResources().getDrawable(R.drawable.ic_book)),
				S006Fragment.class, null);

		mTabHost.getTabWidget().getChildAt(1)
				.setBackgroundResource(R.drawable.tab_selector);
		mTabHost.setBackgroundColor(Color.WHITE);

		mTabHost.setCurrentTab(1);

		mTabHost.setOnTabChangedListener(this);

		// LucLX: set back press button
		imgHeaderBack.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				onBackPressed();
			}
		});
		// -------------------------------

	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
	}

	@Override
	public void onTabChanged(String tabId) {
		int tabID = mTabHost.getCurrentTab();
		mTabHost.getTabWidget().getChildAt(tabID)
				.setBackgroundResource(R.drawable.tab_selector);
		mTabHost.refreshDrawableState();
	}

	
}
